package implementor;

import daoInterface.SizeDao;
import dbhandeling.Crude;
import dto.Sell;
import dto.Size;
import dto.Size;

public class SizeImp extends Crude implements SizeDao{


	String className = new Size().getClass().getName();
	@Override
	public void add(Size cat) throws Exception {
		super.insert(cat);
		
	}

	@Override
	public void update(Size cat) throws Exception {
		super.update(className, "sizeName", cat.getSizeName(),"sizeCode", cat.getautosizeCode()+"");
		
		
	}

	@Override
	public void delete(Size cat) {
		// TODO Auto-generated method stub
		super.delete(className, "sizeCode", cat.getautosizeCode()+"");
		
	}

	@Override
	public Size[] retrieveArray( String conditionField,
			String conditionValue) throws Exception {
		Object[] cat= super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		Size[]s=new Size[cat.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(Size) cat[i];
		return s;
	}

	@Override
	public Size[] retrieveAll() throws Exception {
		Object[] cat= super.retreiveAll(className);
		Size[]s=new Size[cat.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(Size) cat[i];
		return s;
	}

	@Override
	public Size retrieve( String conditionField,
			String conditionValue) throws Exception {
		Size cat=(Size) super.retreive(className, conditionField, conditionValue);
		return cat;
	}

	public int getAutoGenratedKey()
	{
		 int key=super.getAutoGenratedKey(className,"autosizeCode") ;
		 return key;
	}

}
